package com.yidu.action;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.model.LockerAdmin;
import com.yidu.model.LockerUser;
import com.yidu.service.AdminService;
import com.yidu.util.Message;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author roots
 * @since 2018-10-20
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

	@Resource
	private AdminService service;
	
	
	/**
	 * 查询
	 * @return
	 */
	/*
	@RequestMapping("/findByName")
	@ResponseBody
	public Message findByName(LockerAdmin admin) {
		Message msg = new Message();
		List<LockerAdmin> list = service.findByName(admin);
		if(list.size()>0) {
			msg.setState(1);
		}else {
			msg.setState(0);
		}
		return msg;
	}
	*/
	/**
	 * 根据用户名和密码查询
	 * @param admin
	 */
	@RequestMapping("/queryNameOrPwd")
	@ResponseBody
	public Message queryNameOrPwd(LockerAdmin admin) {
		LockerAdmin admin1 = service.queryNameOrPwd(admin);
		Message msg = new Message();
		if(admin1==null) {
			msg.setState(0);
			msg.setMsg("登录失败");
		}else {
			msg.setState(1);
			msg.setMsg("登录成功");
		}
		return msg;
	}
}

